import {systemStoreHook} from "@/stores/modules";
import { commonState } from '@/common/index.js'

const systemStore = systemStoreHook();
export const defaultBreadcrumb = [{
    areaName: '顶级',
    parentId: 0
}];
export const pageSearch = reactive({
    pageNumber: commonState.pageNumber,
    pageSize: commonState.pageSize,
    parentId: 0
});
export const tableState = reactive({
    totalCount: 0,
    records: []
});

export const state = reactive({
    selectedRowKeys: [],
    loading: false,
    subLoading: false,
    breadcrumb: defaultBreadcrumb,
});
export const setLoading = (loading) => {
    state.loading = loading;
}

export const setSubLoading = (loading) => {
    state.subLoading = loading;
}

//表单列表
export const columns = [
    {
        title: '城市名称',
        dataIndex: 'areaName',
        key: 'areaName',
        align: 'center',
        ellipsis: true
    },
    {
        title: '邮政编码',
        dataIndex: 'zipCode',
        key: 'zipCode',
        align: 'center',
        ellipsis: true
    },
    {
        title: '城市路径',
        dataIndex: 'fullName',
        key: 'fullName',
        align: 'center',
        ellipsis: true
    },
    {
        title: '经度',
        dataIndex: 'lng',
        key: 'lng',
        align: 'center',
        ellipsis: true
    },
    {
        title: '纬度',
        dataIndex: 'lat',
        key: 'lat',
        align: 'center',
        ellipsis: true
    },
    {
        title: '操作',
        key: 'operation',
        fixed: 'right',
        align: 'center'
    }
]
export const rules = reactive({
    areaName: [{required: true, message: '请输入城市名称', trigger: 'blur'}],
});
//明细
export const detailState = reactive({})

//设置查询参数
export function setSearchParam() {
    Object.assign(pageSearch, systemStore.getCityAreaSearch);
    return pageSearch;
}
